<!DOCTYPE HTML>
<script src="../../resources/js-test.js"></script>
<style>
  td {
    width: 48px;
    height: 48px;
    outline: solid 1px red;
  }
</style>
<div id="parent" style="width: 65px; height: 65px; border: solid 5px black; overflow: scroll;">
  <table id="Grid" style="width: 150px; border-collapse: collapse;">
    <tr>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </table>
</div>
<script>
  description('Issue crbug.com/295848: element.scrollIntoViewIfNeeded() does not scroll the entire element render box into view.');
  if (window.testRunner)
    testRunner.dumpAsText(true);

  var parent = document.getElementById("parent");
  var table = document.getElementById("Grid");

  table.rows[1].cells[1].scrollIntoViewIfNeeded(false);
  shouldBeEqualToNumber('parent.scrollTop', 50);
  shouldBeEqualToNumber('parent.scrollLeft', 50);

  table.rows[0].cells[0].scrollIntoViewIfNeeded(false);
  shouldBeEqualToNumber('parent.scrollTop', 0);
  shouldBeEqualToNumber('parent.scrollLeft', 0);
</script>
